﻿using Abp.Net.Mail;
using System.Net.Mail;
using System.Threading.Tasks;

namespace Mt.Site.Core.Net.Emailing
{
    public static class EmailSenderExtension
    {
        public static void SendGroup(this IEmailSender sender, string subject, string body, params string[] to)
        {
            var msg = new MailMessage
            {
                To = { },
                Subject = subject,
                Body = body,
                IsBodyHtml = true
            };

            foreach (var item in to)
            {
                msg.To.Add(item);
            }

            sender.Send(msg);
        }

        public static Task SendGroupAsync(this IEmailSender sender, string subject, string body, params string[] to)
        {
            var msg = new MailMessage
            {
                To = { },
                Subject = subject,
                Body = body,
                IsBodyHtml = true
            };

            foreach (var item in to)
            {
                msg.To.Add(item);
            }

            return sender.SendAsync(msg);
        }
    }
}
